
const MESSAGE_TYPE = {
    ACK:"ACK",
    IM:"IM"
}

const CONTENT_TYPE = {
    JSON:'JSON'
}

class SystemWebSocket{

    #options = {};

    constructor(options={}) {
        if(!options || !options.websocket){
            throw new Error("未传入web")
        }
        this.#options.websocket = options.websocket;
    }


    sendChatMessage(receive,msg){
        let chatMsg = {
            type:MESSAGE_TYPE.IM,
            contentType:CONTENT_TYPE.JSON,
            content:msg
        };
        this.#options.websocket.send(JSON.stringify(chatMsg));
    }

    sendGroupMessage(){

    }

    sendAckMessage(receive,msg){
        let ack = {
            type:MESSAGE_TYPE.ACK,
            contentType:CONTENT_TYPE.JSON,
            content:msg
        };
        this.#options.websocket.send(JSON.stringify(ack));
    }

}


export default SystemWebSocket;

















